package com.water.smartfarm.main;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.water.smartfarm.R;

public class ControlFragment extends Fragment implements View.OnClickListener{
    private View mRootView = null;
    private Button openSwitch;
    boolean flag = true;
    private void initView() {
        openSwitch = (Button) mRootView.findViewById(R.id.openSwitch);
        openSwitch.setOnClickListener(this);
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mRootView = inflater.inflate(R.layout.fragment_control, container, false);
        initView();
        return mRootView;
    }


    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
            case R.id.openSwitch:
                if(flag){
                    openSwitch.setText(R.string.close_light);
                }else{
                    openSwitch.setText(R.string.open_light);
                }
                flag = !flag;
                break;
        }
    }
}
